home *** CD-ROM | disk | FTP | other *** search
- Subject: Re: Initializing an Extension
- Sent: 3/5/96 4:27 PM
- Received: 3/5/96 4:41 PM
- From: Troy Gaul, tgaul@apple.com
- Reply-To: ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- >Damon describes the static method MyCreateXYZProc which makes the call:
- >
- >> theExtension -> InitMySOMNautilusShellExtension (ev, part ->
- >> GetODPart (ev));
- >
- >OK, so consider InitMySOMNautilusShellExtension. There I would like to get
- >access to an object owned by my part and stash a reference to it in the
- >extension. OpenDoc's SoundEditor extension, for example, initializes a field
- >
- > SoundEditor* fOwner
- >
- >using the call
- >
- > fOwner = ((SampleCode_som_SoundEditor*) owner->GetRealPart(ev))
- > ->GetImplementation(ev);
-
- This was an unfortunage decision, as it means that the SOM object must
- have the additional function GetImplementation, and as you can see, you
- have to call GetRealPart/ReleaseRealPart to get access to the part
- through the part wrapper. Instead, the SoundEditor example could have
- defined it's InitXxxxExtension routine to take a SoundEditor* as a
- parameter. This was actually suggested to me, but too late to make the
- change. (I worked on maintenence for the SoundEditor sample part -- I
- didn't design the way this was done, though.)
-
- >How do I do that in ODF? The GetRealPart method will return an ODPart, but
- >what I really want is my FW_CPart, the one, if I understand things correctly,
- >that is holding onto the ODPart in its fODPart field. (I want my FW_CPart
- >because it has a pointer to an object that I want to stash in my extension
- >and refer to from another part.)
-
- Since the FW_CPart is passed into the creation proc, you can pass that
- along to your extension subclass, like:
-
- ODExtension*
- CMyPart::MyCreateXYZProc(Environment* ev, FW_CPart* part, const char*
- name)
- {
- SOM_MyXYZExtension* theExtension = new
- SOMXTN_MySOMNautilusShellExtension();
- theExtension->InitMyExtension(ev, (CMyPart*) part);
-
- return theExtension;
- }
-
- Since you are the one defining your Init routine, you can define it with
- whatever parameters you want. However, since ODF calls your creating
- proc and the creation proc has the given set of parameters, that's all
- the information you really get access to when initing your extension.
-
- Since the FW_CPart is passed in, though, (and you know that this will
- actually be of type CMyPart or whatever) you can pass this into your
- extensions Init routine, or you can get information from the part and
- pass that to the extension instead.
-
- _troy
-
- ......................................................................
- Troy Gaul tgaul@apple.com
- Apple Computer, Inc. OpenDoc Added Value Products
- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-
-